<template>
  <section>
    <div class="filter-container">
      <el-select class="w100" size="mini" v-model="listQuery.status" placeholder="状态" clearable>
        <el-option label="全部" value="0"></el-option>
        <el-option label="已经分佣" value="2"></el-option>
        <el-option label="已结算" value="3"></el-option>
        <el-option label="已冻结 " value="4"></el-option>
        <!-- <el-option label="首年入驻费" value="1"></el-option>
            <el-option label="首年入驻费" value="2"></el-option>
            <el-option label="充值红包" value="3"></el-option>
            <el-option label="小店买单" value="4"></el-option>
            <el-option label="买小店商品" value="5"></el-option>
            <el-option label="平台商品" value="6"></el-option>
            <el-option label="手动调整" value="7"></el-option> -->


      </el-select>
      <common-input @keyup.enter.native="handleFilter" class="w200 ml10" placeholder="关键字"
        v-model="listQuery.keyword" />
      <common-input @keyup.enter.native="handleFilter" class="w200 ml10" placeholder="备注" v-model="listQuery.remark" />

      <el-button size="mini" class="ml10" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
    </div>
    <el-table :data="list" style="width: 100%">
      <el-table-column align="left" label="uid">
        <template slot-scope="scope">
          <span>{{ scope.row.uid }}</span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="昵称">
        <template slot-scope="scope">
          <span>{{ scope.row.nickName }}</span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="手机号">
        <template slot-scope="scope">
          <span>{{ scope.row.mobile }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态">
        <template slot-scope="scope">
          <span>{{ scope.row.statusText }}</span>
        </template>
      </el-table-column>
      <el-table-column align="right" label="资金">
        <template slot-scope="scope">
          <span v-if="scope.row.money < 0">-{{ scope.row.money }}元</span>
          <span v-else>+{{ scope.row.money }}元</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="时间" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createAt) }}</span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="订单号">
        <template slot-scope="scope">
          <span>{{ scope.row.orderid ? scope.row.orderid : scope.row.orderNo }}</span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="备注">
        <template slot-scope="scope">
          <span>{{ scope.row.remark }}</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page.sync="listQuery.page" :page-sizes="[20, 30, 50]" :page-size="listQuery.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
    </div>
  </section>
</template>

<script>
import {
  money_list, commissionRecordList
} from '../../api/member';
export default {
  components: {
  },
  // props: {
  //     formData: Object,
  //     uid: Number
  // },
  props: ['uid'],

  data() {
    return {
      list: null,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 20,
        keyword: undefined,
        remark: undefined,
        uid: this.uid,
        status: undefined,
      },
      total: null,
    };
  },
  mounted() {
    console.log('uid:', this.uid)
  },
  watch: {
    uid(newValue) {
      if (newValue) {
        this.listQuery.uid = newValue
        this.getList()
      }
    }
  },

  created() {
    this.getList();
  },

  methods: {
    getList() {
      this.listLoading = true;
      commissionRecordList(this.listQuery).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.listLoading = false;
      })
    },
    handleFilter() {
      this.listQuery.pageNum = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.getList();
    },
  }
};
</script>
